package o;

import android.text.InputFilter;
import android.text.Spanned;

public class bym implements InputFilter {
    private final int ˊ;
    private bys ˏ;

    public bym(int i, bys o_bys) {
        this.ˊ = i;
        this.ˏ = o_bys;
    }

    public CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
        int length = this.ˊ - (spanned.length() - (i4 - i3));
        if (length <= 0) {
            ˎ();
            return "";
        } else if (length >= charSequence.length()) {
            return charSequence;
        } else {
            length += i;
            if (Character.isHighSurrogate(charSequence.charAt(length - 1))) {
                length--;
                if (length == i) {
                    return "";
                }
            }
            ˎ();
            return charSequence.subSequence(i, length);
        }
    }

    private void ˎ() {
        if (this.ˏ != null) {
            this.ˏ.ˊ();
        }
    }
}
